<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>基本信息</title>
    <%@ include file="/WEB-INF/include/common.jsp"%>
    <%@ include file="/WEB-INF/include/commoncss.jsp"%>

    <style type="text/css">
        #uploader .placeholder .webuploader-pick{
            background:#5eb95e
        }
        #table_body button{
            margin:3px
        }
    </style>
</head>
<body>
<div class="page-container">
    <form action="${ctx }/BaseInformation/InfoSearch" method="post" class="text-c">

        大洲:
        <span class="select-box" style="width:80px ;">
				<select id="continent" name="continent" class="select">
					<option value="-1">全部</option>
					<c:forEach items="${clist }" var="t">
                        <option value="${t.continent_id }">${t.continent_name }</option>
                    </c:forEach>
				</select>
			</span>
        录入者账户:<input id="recoder_id" name="recoder_id" class="input-text" style="width: 100px;"/>

        中文名字:<input id="nation_z" name="nation_z" class="input-text" style="width:100px;">
        英文名字:<input id="nation_e" name="nation_e" class="input-text" style="width:100px;">
        <button type="submit" class="btn btn-success radius" onclick="">
            <i class="Hui-iconfont">&#xe665;</i> 查询
        </button>
    </form>
    <div class="content">
        <div class="cl pd-5 bg-1 bk-gray mt-20">

            <%---------------------------------------------------------------------------------------------------%>
            <%--<span class="select-box">--%>
               <%--<select class="select" size="1" id="selectFileKind">--%>
                   <%--<option value="0" selected>上传国家信息excel文件</option>--%>
                   <%--<option value="1">上传区位地图压缩包文件（命名规范：locationMaps.zip）</option>--%>
                   <%--<option value="2">上传国徽压缩包文件（命名规范：nationalEmblems.zip）</option>--%>
                   <%--<option value="3">上传国旗压缩包文件（命名规范：nationalFlags.zip）</option>--%>
                   <%--<option value="4">上传国歌压缩包文件（命名规范：nationalSongs.zip）</option>--%>
               <%--</select>--%>
            <%--</span>--%>
            <%--<span class="btn-upload form-group">--%>

                <%--<input class="input-text upload-url radius" type="text" name="uploadfile-1"  readonly value="命名必须规范哦" style="color: #999999"/><a href="javascript:upload_flag_ZIP();" class="btn btn-primary radius"style="z-index: 999">上传文件</a>--%>
                <%--<input type="file" name="file-1" class="input-file" id="uploadfile-1" style="width: 290px;right: 100px;"/>--%>
            <%--</span>--%>
                <%-----------------------------------------------------------------------------------------------%>
            <span class="r">
                <button type="button" class="btn btn-success radius" onclick="addBaseinfo()">添加</button>
            共有数据：<strong id="listsize">${nlist.size()} </strong> 条</span>

                <%--<input class="input-text upload-url radius" type="text" name="uploadfile-1"  readonly value="命名必须规范哦" style="color: #999999"><a id="uploadFile" class="btn btn-primary radius"style="z-index: 999">上传文件</a>
                <input type="file" name="file-1" class="input-file" id="uploadfile-1" style="width: 290px;right: 100px;">--%>
            </span>


<%--
            <span class="r">共有数据：<strong id="listsize">${infolist.size()} </strong> 条</span>
--%>

        </div>
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th>国家代码</th>
                <th>中文名字</th>
                <th>英文名字</th>
                <!-- <th >公告内容</th> -->
                <th >大洲</th>
                <th>建国时间</th>
                <th >首都</th>
                <th >国土面积</th>
                <th>操作人</th>
                <th>操作时间</th>
                <th >操作</th>
            </tr>
            </thead>
            <tbody id="table_body">
            <c:forEach items="${nlist }" var="i">
                <tr class="text-c">
                    <td width="100px">${i.country_code }</td>
                    <td>${i.nation_z}</td>
                    <td>${i.nation_e }</td>
                    <td>${i.continent_name }</td>
                    <td>${i.establish_time }</td>
                    <td>${i.capital }</td>
                    <td><fmt:formatNumber type="number" value="${i.country_area }"/></td>
                    <td>${i.recoder_id}</td>
                    <td>${i.recoder_time}</td>
                    <td>
<%--
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="upload_statistics(this.value)"><i class="Hui-iconfont">&#xe6df;</i> 导入统计</button>
--%>
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="nationinfo_update(this.value)"><i class="Hui-iconfont">&#xe685;</i> 修改</button>
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="nationinfo_delete(this.value)"><i class="Hui-iconfont">&#xe685;</i> 删除</button>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<%@ include file="/WEB-INF/include/commonjs.jsp"%>
<script type="text/javascript" src="${ctx}/javascript/laydate/laydate.js"></script>
<script type="text/javascript">
    $(function(){
        $('table tbody tr:odd').css("background-color","#f5f5f5");
        $('.table-sort').dataTable({
            "aaSorting": [[ 0, "desc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[1,2,3,4]}// 制定列不参与排序
            ]
        });
        $('.table-sort tbody').on( 'click', 'tr', function () {
            if ( $(this).hasClass('selected') ) {
                $(this).removeClass('selected');
            }
            else {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
        });
    });
</script>
<script type="text/javascript">
    function nationinfo_detail(value){
        url="${ctx }/BaseInformation/nationinfo_detail?country_code="+value;
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
    function nationinfo_update(value){
        url="${ctx }/BaseInformation/nationinfo_update?country_code="+value;
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
    function nationinfo_delete(value){
        url="${ctx }/BaseInformation/baseinfo_delete";
        layer.confirm("确认删除吗？",['确认','取消'],function () {
            var parameter={country_code:value};
            $.post(url,parameter,function (data) {
                if(data=="删除成功"){
                    layer.msg(data,{icon:1,time:2000},function(){
                        location.reload(true);
                    })
                }else{
                    layer.msg(data,{icon:2,time:2000});
                }
            });
        })
    }
//    上传文件
    var urlLink="${ctx }/BaseInformation/uploadNationFile.do";

//    判断命名规范

    var rightName=["locationMaps","nationalEmblems","nationalFlags","nationalAnthems"];
    function judgeNameIsRight(fileName,index) {
        if (fileName != rightName[index-1] || fileName==null || fileName==""){
            return false;
        }else{
            return true;
        }
    }
    function addBaseinfo(){
        url="${ctx }/BaseInformation/nationinfo_add";
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
    function upload_statistics(value){
        url="${ctx }/BaseInformation/upload_statistics?country_code="+value;
        title="统计数据上传";
        layer_show(title,url,document.body.clientWidth*0.4,document.body.clientHeight*0.2);
//        var index=layer.open({
//            type:2,
//            content:url
//        });
//        layer.full(index);
    }

    var rightName=["locationMaps","nationalEmblems","nationalFlags","nationalSongs"];


</script>
</body>
</html>